﻿@model Solution.Business.Entities.News

@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
@if(Session["Admin"] != null)
{
<h2>Create</h2>
<script src="@Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("select#TinhId").change(function (evt) {

                if ($("select#TinhId").val() != null) {

                    $.ajax({
                        url: "/AdminNews/GetQuanId1",
                        type: 'POST',
                        data: { TinhId: $("select#TinhId").val() },
                        success: function (response) {
                            $("select#QuanId").replaceWith(response)
                        },
                        error: function (xhr) {
                            alert("Something went wrong, please try again");
                        }
                    });
                }
            });
        });
    </script>


    using (Html.BeginForm("Create", "AdminNews", FormMethod.Post, new { enctype = "multipart/form-data"  }))
    {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>News</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.Title)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Title)
            @Html.ValidationMessageFor(model => model.Title)
             <span style="color:red;">*</span>
        </div>       

        <div class="editor-label">
            @Html.LabelFor(model => model.Content)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Content, new { @id = "ckeContent" })
            <script type="text/javascript">
                CKEDITOR.replace("ckeContent");
            </script>
             <span style="color:red;">*</span>
        </div>

         <div class="editor-label">
            @Html.Label("Hình ảnh đại diện:")
        </div>
        <div class="editor-field">
            <input type="file" name="file" id="file" />
             <span style="color:red;">*</span>
        </div>

        
        <div class="editor-label">
            @Html.LabelFor(model => model.Price, "Giá :")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Price)
            @Html.ValidationMessageFor(model => model.Price)
             <span style="color:red;">*</span>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.PmId, "Loại tiền :")
        </div>
        <div class="editor-field">
            @Html.DropDownList("PmId", String.Empty)
            @Html.ValidationMessageFor(model => model.PmId)
             <span style="color:red;">*</span>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Acreage, "Diện tích :")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Acreage)
            @Html.ValidationMessageFor(model => model.Acreage)
             <span style="color:red;">*</span>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.UnId, "Đơn vị tính :")
        </div>
        <div class="editor-field">
            @Html.DropDownList("UnId", String.Empty)
            @Html.ValidationMessageFor(model => model.UnId)
             <span style="color:red;">*</span>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Address, "Địa chỉ :")
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Address)
            @Html.ValidationMessageFor(model => model.Address)
             <span style="color:red;">*</span>
        </div>
        
        <div class="editor-label">
            @Html.LabelFor(model => model.TrId, "Loại hình bất động sản :")
        </div>
        <div class="editor-field">
            @Html.DropDownList("TrId", String.Empty)
            @Html.ValidationMessageFor(model => model.TrId)
             <span style="color:red;">*</span>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Location.LId, "Tỉnh :")
        </div>
        <div class="editor-field">
            @Html.DropDownList("TinhId", String.Empty)
            @Html.ValidationMessageFor(model => model.Location.LId)
             <span style="color:red;">*</span>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LId, "Quận/Huyện :")
        </div>
        
        <select id="QuanId" name="QuanId">

        </select>

        <div class="editor-label">
            @Html.LabelFor(model => model.DId, "Hướng bất động sản :")
        </div>
        <div class="editor-field">
            @Html.DropDownList("DId",String.Empty)
            @Html.ValidationMessageFor(model => model.DId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LgId, "Tình trạng pháp lý :")
        </div>
        <div class="editor-field">
            @Html.DropDownList("LgId", String.Empty);
            @Html.ValidationMessageFor(model => model.LgId)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Position, "Vị trí tin :")
        </div>
        <div class="editor-field">
        <select id="Position" name="Position">
            <option value="-1">Select...</option>
            <option value="0">Vị trí VIP</option>
            <option value="1">Vị trí bình thường</option>
        </select>
             <span style="color:red;">*</span>
        </div>

        <div class="editor-label">
            @Html.Label("Hình ảnh 1:")
        </div>
        <div class="editor-field">
            <input type="file" name="file1" id="file1" />
        </div>

       <div class="editor-label">
            @Html.Label("Hình ảnh 2:")
        </div>
        <div class="editor-field">
            <input type="file" name="file2" id="file2" />
        </div>

        <div class="editor-label">
            @Html.Label("Hình ảnh 3:")
        </div>
        <div class="editor-field">
            <input type="file" name="file3" id="file3" />
        </div>

        <div class="editor-label">
            @Html.Label("Hình ảnh 4:")
        </div>
        <div class="editor-field">
            <input type="file" name="file4" id="file4" />
        </div>

        <div class="editor-label">
            @Html.Label("Hình ảnh 5:")
        </div>
        <div class="editor-field">
            <input type="file" name="file5" id="file5" />
        </div>

        <div class="editor-label">
            @Html.Label("Hình ảnh 6:")
        </div>
        <div class="editor-field">
            <input type="file" name="file6" id="file6" />
        </div>

        <div class="editor-label">
            @Html.Label("Hình ảnh 7:")
        </div>
        <div class="editor-field">
            <input type="file" name="file7" id="file7" />
        </div>

        <div class="editor-label">
            @Html.Label("Hình ảnh 8:")
        </div>
        <div class="editor-field">
            <input type="file" name="file8" id="file8" />
        </div>

        <div class="editor-label">
            @Html.Label("Hình ảnh 9:")
        </div>
        <div class="editor-field">
            <input type="file" name="file9" id="file9" />
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Video)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Video, new { @id = "ckeVideo" })
            <script type="text/javascript">
                CKEDITOR.replace("ckeVideo");
            </script>
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Map)
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.Map, new { @id = "ckeMap" })
            <script type="text/javascript">
                CKEDITOR.replace("ckeMap");
            </script>
        </div>
        <div class="editor-label">
            @Html.LabelFor(model => model.Status, "Trạng thái hiển thị :")
        </div>
        <div class="editor-field">
        <select id="Status" name="Status">
            <option value="0">Select...</option>
            <option value="1">Hiện</option>
            <option value="2">Ẩn</option>
        </select>
             <span style="color:red;">*</span>
        </div>
        <p>
            <input type="submit" value="Create" />
        </p>
    </fieldset>
    }

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
}

else
{
    <a href="@Url.Content("~/AdminLogin/Error")"></a>
}